cmake_minimum_required(VERSION 3.13)

project(cppext VERSION 0.1.0.0)

set(CMAKE_CXX_STANDARD 17)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)

include_directories(include)

set(${PROJECT_NAME}_src src/empty.cpp)

add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_src})

add_subdirectory(test)

include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
set(PROJECT_EXPORT_TARGETS ${PROJECT_NAME})
set(PROJECT_EXPORT_NAME ${PROJECT_NAME})
set(PROJECT_INSTALL_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})

foreach(target ${PROJECT_EXPORT_TARGETS})
  add_library(${PROJECT_EXPORT_NAME}::${target} ALIAS ${target})  
endforeach()

install(
  TARGETS ${PROJECT_EXPORT_TARGETS}
  EXPORT ${PROJECT_EXPORT_NAME}Targets
  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
  INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(
  DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include
  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)



set(CMAKE_INSTALL_PREFIX "./install")
install(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT Devel)
install(DIRECTORY "include/libcppext" DESTINATION include COMPONENT Devel)

